#pragma once

#include	<Singleton.h>
#include	<map>
#include	<string>
#include	<vector>

#if defined(__GNUC__)
#	if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
#		define	USE_CPP_REGEX	0
#	else
#		define	USE_CPP_REGEX	1
#	endif
#else
#	define	USE_CPP_REGEX	1
#endif

#if USE_CPP_REGEX
#	include	<regex>
#else
#	include	<regex.h>
#endif

class TextFilter : public ISingleton<TextFilter> {
public:
	TextFilter() : _badwords(), _regex(nullptr) {}

	bool Initialize();
	bool Check(const std::string & words);
	uint32_t Char(char * p, size_t & l);

private:
	std::map<uint32_t, std::vector<std::string>> _badwords;

#if USE_CPP_REGEX
	std::regex * _regex;
#else
	regex_t * _regex;
#endif
};